#include "cpu/exec/template-start.h"
#include "cpu/decode/modrm.h"
#define instr jmp

static void do_execute() {
	cpu.eip += op_src->val;
	print_asm(str(instr) " %x", cpu.eip + 1 + DATA_BYTE);
}

make_instr_helper(si)
#if DATA_BYTE == 4
make_helper(jmp_rm_l) {
    // Log("op_src->val = %x", op_src->val);

	// int len = decode_rm_l(eip + 1);
    // // Log("len = %d", len);
	// cpu.eip = op_src->val - (len + 1);
    // // Log("cpu.eip = %x", cpu.eip);
	// print_asm(str(instr) " *%s", op_src->str);
	// return 0;
    	int len = decode_rm_l(eip + 1);
	cpu.eip = op_src->val - (len + 1);
	print_asm(str(instr) " *%s", op_src->str);
	return len + 1;
}
#endif

#if DATA_BYTE == 2 || DATA_BYTE == 4

//0x76
make_helper(jbe_si_b) {
    // 如果ZF=1或CF=1，转移
    int len = decode_i_b(eip + 1);
    // Log("op_src->val = %x", op_src->val);
    if(cpu.eflags.ZF == 1 || cpu.eflags.CF == 1) {
        cpu.eip = cpu.eip + (int8_t)op_src->imm + 2;
        // Log("cpu.eip = %x", cpu.eip);
        return 0;
    }
    // Log("len = %d", len);
    else {
        return len + 1;
    }
    return len + 1;
}
#endif

// #if DATA_BYTE == 1 || DATA_BYTE == 4

// #endif

#include "cpu/exec/template-end.h"

